package com.example.web;

import java.util.Date;
import java.util.TimerTask;

/**
 * 定时任务:垃圾回收 Timer
 * */
public class GarbageCollectionTimer extends TimerTask {

	@Override
	public void run() {
		task();
	}
	//垃圾回收任务
	private void task() {
		Runtime rt = Runtime.getRuntime();
		rt.gc();
		System.out
				.println(new Date().toString()
						+ " [INFO] Garbage Collection Task started...,freeMemory size:(bytes)"
						+ rt.freeMemory());
	}
}
